//提现 转账 充值认证
import {
  get_withdrawal,
  get_recharge,
  recharge_audit,
  withdrawal_audit,
} from "@/api/record";
export default {
  namespaced: true,
  state: {
    page: 1,
    limit: 10,
    status: -1, // 提现申请状态
    total: "", // 总数
    rows: [],
    phone: "", //电话号码
    info: {}, // 审核信息
  },
  mutations: {
    toggle: (state, payload) => {
      state.rows = payload.rows;
      state.total = payload.total;
      console.log(state);
    },
    modify: (state, payload) => {
      state.info = payload;
    },
    phone: (state, payload) => {
      state.phone = payload;
    },
    changeState: (state, payload) => {
      state.status = payload;
    },
  },
  actions: {
    withdrawal: async ({ commit, state }) => {
      const { page, limit, status } = state;
      const data = await get_withdrawal({ page, limit, status });
      commit("toggle", data);
    },
    recharge: async ({ commit, state }) => {
      const { page, limit, phone } = state;
      if (phone !== "") {
        const data = await get_recharge({ page, limit, phone });
        commit("toggle", data);
      } else {
        const data = await get_recharge({ page, limit });
        commit("toggle", data);
      }
    },
    recharge_agree: async ({ state }) => {
      const { info } = state;
      const { success } = await recharge_audit(info);
      return success;
    },
    withdrawal_refuse: async ({ state }) => {
      const { info } = state;
      const { success } = await recharge_audit(info);
      return success;
    },

    withdrawal_agree: async ({ state }) => {
      const { info } = state;
      const { success } = await withdrawal_audit(info);
      return success;
    },
    recharge_refuse: async ({ state }) => {
      const { info } = state;
      const { success } = await withdrawal_audit(info);
      return success;
    },
  },
  getters: {},
};
